﻿using Ninject.Modules;
using PgBirdie.Console.Command;
using PgBirdie.Core.Dump;
using PgBirdie.Core.Dump.v9_x;
using PgBirdie.Core.Service.Compare;
using PgBirdie.Core.Service.DbObject;
using PgBirdie.Core.Service.Delta;
using PgBirdie.Core.Service.Dump;
using PgBirdie.Core.Service.Infrastructure;
using PgBirdie.Core.Service.SourceControl;

namespace PgBirdie.Console
{
    public class ServiceModule : NinjectModule
    {
        public override void Load()
        {
            // Commands
            Bind<ICommand>().To<DeltaCommand>().Named("Delta");
            Bind<ICommand>().To<DumpCommand>().Named("Dump");
            Bind<ICommand>().To<DumpCommand>().Named("Restore");

            // Compare
            Bind<ICompareExtractService>().To<CompareExtractService>().InSingletonScope();
            Bind<ICompareService>().To<CompareService>().InSingletonScope();

            // DbObject
            Bind<IDbObjectFromDbService>().To<DbObjectFromDbService>().InSingletonScope();            
            Bind<IDbObjectToSqlService>().To<DbObjectToSqlService>().InSingletonScope();
            Bind<IDbObjectValidator>().To<DbObjectValidator>().InSingletonScope();

            // Delta
            Bind<IDeltaStaticDataDbObjectToSqlService>().To<DeltaStaticDataDbObjectToSqlService>().InSingletonScope();
            Bind<IDeltaStructureDbObjectToSqlService>().To<DeltaStructureDbObjectToSqlService>().InSingletonScope();

            // Dump
            Bind<IDbFromPgDumpService>().To<Core.Service.Dump.v9_x.DbFromPgDumpService>().InSingletonScope();
            Bind<IDbObjectFromPgDumpService>().To<DbObjectFromPgDumpService>().InSingletonScope();
            Bind<IDumpToDiskService>().To<DumpToDiskService>().InSingletonScope();                        
            Bind<IPgDumpService>().To<PgDumpService>().InSingletonScope();
            Bind<IRestoreDatabaseSql>().To<RestoreDatabaseSql>().InSingletonScope();

            // Infrastructure
            Bind<IFileSystemService>().To<FileSystemService>().InSingletonScope();
            Bind<ISystemApplicationService>().To<SystemApplicationService>().InSingletonScope();
            Bind<ITextFormatService>().To<TextFormatService>().InSingletonScope();

            // Source control
            Bind<IDbFromSourceControlService>().To<DbFromSourceControlService>().InSingletonScope();
            Bind<IDbObjectFromSourceControlService>().To<DbObjectFromSourceControlService>().InSingletonScope();
        }
    }
}